<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>资金申请单详情</title>
    <#include "/common/resource.ftl">
    <script type="text/javascript">
        var getResultData = function() {
            $.ajaxRequest({
                url: '${params.contextPath}/web/workflowHistory/queryList',
                data: {formId: "${params.formId!}"},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var list = data.data || [];
                    if (list.length <= 0) {
                        $(".layui-timeline").html("--暂无数据--");
                        return;
                    }
                    for (var i = 0; i < list.length; i ++) {
                        var item = list[i];
                        item.rejectClass = item.status == 3 ? "reject-item" : "accept-item";
                    }
                    var html = $.template("result-template", {list : list});
                    $(".layui-timeline").html(html);
                }
            });
        };
        $(function () {
            <#if (params.id)??>
                $.ajaxRequest({
                    url: '${params.contextPath}/web/capitalApply/query.json',
                    data: {id: "${params.id}"},
                    success: function (data) {
                        if (!data.success) {
                            $.message(data.message);
                            return;
                        }
                        var record = data.data;
                        for (var key in record) {
                            $("[field='" + key + "']").html(record[key]);
                        }
                        getResultData();
                    }
                });
            </#if>

            <#if (params.his!) != 1>
                $(".submit-button").click(function () {
                    var type = $(this).attr("data-type") || "";
                    try {
                        parent.submitapproval(type);
                    } catch (e) {
                        var url = "";
                        if (type == "submit") {
                            url = "${params.contextPath}/view/base/workflowTask/workflowTask_approval.htm?mobile=1";
                        } else if (type == "reject") {
                            url = "${params.contextPath}/view/base/workflowTask/workflowTask_reject.htm?mobile=1";
                        }
                        url += "&workflowDefineId=${params.workflowDefineId!}";
                        url += "&taskId=${params.taskId!}";
                        url += "&stepNum=${params.stepNum!}";
                        location.href = url;
                    }
                });
            </#if>
        });
    </script>
    <style>
        body{background:#eee;}
        .layui-table th{font-weight:bold;}
    </style>
</head>
<body>
<div style="padding:10px;">
    <div class="layui-card">
        <div class="layui-card-header">基本信息</div>
        <div class="layui-card-body">
            <table class="layui-table ui-table">
                <tr>
                    <th>申请人</th>
                    <td field="createName">--</td>
                </tr>
                <tr>
                    <th>申请日期</th>
                    <td field="happenDateStr">--</td>
                </tr>
                <tr>
                    <th>部门</th>
                    <td field="deptName">--</td>
                </tr>
                <tr>
                    <th>资金用途</th>
                    <td field="content">--</td>
                </tr>
                <tr>
                    <th>申请金额</th>
                    <td field="amount">--</td>
                </tr>
                <tr>
                    <th>备注</th>
                    <td field="remark">--</td>
                </tr>
            </table>
        </div>
    </div>

    <#if (params.his!) != 1>
        <div class="layui-row" style="background:#fff;margin-bottom:10px;padding:10px;text-align:center;">
            <div class="layui-col-xs6 layui-col-sm6">
                <button type="button" class="layui-btn submit-button" data-type="submit"><i class="fa fa-check"></i> 同意</button>
            </div>
            <div class="layui-col-xs6 layui-col-sm6">
                <button type="button" class="layui-btn submit-button layui-btn-danger" data-type="reject"><i class="fa fa-close"></i> 驳回</button>
            </div>
        </div>
    </#if>
    <script id="result-template" type="text/html" style="display: none">
        {{ each list item index }}
        <li class="layui-timeline-item">
            <i class="layui-icon layui-timeline-axis">&#xe63f;</i>
            <div class="layui-timeline-content layui-text">
                <h3 class="layui-timeline-title">{{item.createTimeStr}} <span class="layui-bg-red" style="padding:2px 5px;border-radius:2px;">{{item.stepName}}</span></h3>
                <div class="{{item.rejectClass}}">
                    <p style="color:#1E9FFF"><i class="fa fa-user"></i> 审批人：{{item.executorName}}</p>
                    <p><span style="color:#FF5722"><i class="fa fa-bookmark"></i> 审批意见：</span>{{item.remark}}</p>
                </div>
            </div>
        </li>
        {{ /each }}
    </script>
    <div class="layui-card">
        <div class="layui-card-header">流程跟踪</div>
        <div class="layui-card-body">
            <ul class="layui-timeline"></ul>
        </div>
    </div>

</div>

</body>

</html>
